home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 328 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.5 KB  |  58 lines

  1. Path: news.uni-stuttgart.de!schweikh
  2. From: schweikh@itosun.ito.uni-stuttgart.de (Jens Schweikhardt)
  3. Newsgroups: comp.infosystems.www.misc,comp.lang.misc,comp.lang.perl.misc,comp.lang.c
  4. Subject: Re: Perl vs.C (was Re: Unix or NT? Get a Mac!)
  5. Date: 4 Jan 1996 13:52:36 GMT
  6. Organization: Comp.Center (RUS), U of Stuttgart, FRG
  7. Message-ID: <4cgm34$qhg@info4.rus.uni-stuttgart.de>
  8. References: <4cgk4a$pje@hecate.umd.edu>
  9. NNTP-Posting-Host: itosun.ito.uni-stuttgart.de
  10.  
  11. In article <4cgk4a$pje@hecate.umd.edu>, Ram Samudrala <me@ram.org> wrote:
  12. >I'm posting this on comp.lang.c, and removing c.i.w.authoring.cgi.
  13. >
  14.  
  15. [deletia]
  16.  
  17. >--Ram
  18.  
  19. Because you posted this on comp.lang.c, let me hint you at the following.
  20. You obviously interchanged the return types of the two functions, main
  21. and regerr. The latter should return void, the former must return int
  22. according to the standard :-)
  23.  
  24.  
  25.     #include <stdio.h>
  26.  
  27.     #define INIT register char *sp = instring;
  28.     #define GETC() (*sp++)
  29.     #define PEEKC() (*sp)
  30.     #define UNGETC(c) (--sp)
  31.     #define RETURN(c) return;
  32.     #define ERROR(c) regerr(c)
  33.     #define ESIZE 20000
  34.  
  35.     #include <regexp.h>
  36.  
  37.     void main(int argc, char *argv[])  /* void main, a no-no on clc */
  38.     {
  39.       char expbuf[ESIZE], line[200];
  40.  
  41.       compile(argv[1], expbuf, &expbuf[ESIZE], '\0');
  42.       while (gets(line))
  43.         {
  44.           if (step(line, expbuf))
  45.         printf("match found in %s\n", line);
  46.         }
  47.     }
  48.  
  49.     int regerr(int c)
  50.     {
  51.       fprintf(stderr, "regerr(): an error has occured: %d!\n", c);
  52.       exit(0);
  53.     }
  54.  
  55. Bye, Jens
  56. -- 
  57. SIGSIG -- signature too long (core dumped)
  58.